﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Windows;
using Microsoft.Practices.Prism.Mvvm;
using FinPlusAssembler;
using FinPlusInterfaces;

namespace FinPlusCompView
{
    public partial class FinPlusView : FinPlusControl, IView
    {
        [State(Test = true)]
        public override bool IsValid { get; set; }
        [State(Save = true)]
        public new double Height { get { return base.Height; } set { base.Height = value; } }
        [State(Save = true)]
        public new double Width { get { return base.Width; } set { base.Width = value; } }
        [State(Test = true)]
        public override string TestString { get { return Adapter.ToString(); } }
        public override IPods Adapter { get { return base.Children(grid.Children); } }

        //construct
        public FinPlusView(string templatePath, string name, Env env, string query ="")
        {
            InitializeComponent();
            Config = Name = name;
            Env = env;

            var view = IOC.New<IPods>(templatePath + ".view", "root/current", query).Construct(name, Env, null);
            LinkedId = view.LinkedId;
            grid.Children.Add((UIElement)view.Object);

            IsValid = true;
        }

        public override void Dispose()
        {
            try
            {
                DI.Dispose(LinkedId);
            }
            catch (Exception e)
            {
                Level.Error.Log(Id, Config, e.Message, e);
            }
        }
    }
}














































































































































































//Copyright2013<jnrton>AllRightsReserved 
//Contact j.nrton@finpus